package com.cet.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequiredArgsConstructor
public class ChatHelloController {


    // 千问模型
    private final ChatModel chatModel;

    @GetMapping("/hello/dochat")
    public String doChat(@RequestParam(name = "message", defaultValue = "你是谁") String message) {
        return chatModel.call(message);
    }

    @GetMapping("/hello/stream/chat")
    public Flux<String> streamChat(@RequestParam(name = "message", defaultValue = "你是谁") String message) {
        return chatModel.stream(message);
    }
}
